﻿<%@ Page Language="C#" MasterPageFile="~/WebSite.Master" AutoEventWireup="true" CodeBehind="BmDownloadManage.aspx.cs"
    Inherits="RN.ERP.Web.Exam.BmDownloadManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <script type="text/javascript">
        function OpenAlert(text,func) {
            $.ligerDialog.warn(text,func);
            return false;
        }

        function RefreshWin() {
            location.href = location.href;
        }
        
        $(function () {
            
            $("#hidFileID").val("");
            $("#fileListGrid .row-radio").click(function () {
                var self = $(this);
                var hidID = $("#hidFileID").val();

                $("#hidFileID").val(this.id);
                $("#txtFileName").val(self.attr("fileName"));
                $("#hidOperaType").val("replace");
            });
        });

        function OperateReplace() {
            if(!!$("#hidFileID").val()){
                $("#btnSave").text("上传替换文件");
                $("#uploadArea").slideDown(500);
            }else{
                OpenAlert("请选择要进行替换的文件！");
            }
        }

        function OperateDel() {
            if ($("#hidFileID").val() === "") {
                OpenAlert("请选择要删除的文件！");
            }else{
                $.ligerDialog.confirm("您确定要删除该项？", function (rst) {
                    if (rst) {
                        $("#hidOperaType").val("del");
                        $("#btnSave").text("上传替换文件");
                        $("#btnUpload").click();
                    }
                });
            }
        }

        function OperateAdd() {
            $("#hidOperaType").val("add");
            $("#txtFileName").val("");
            $("#btnSave").text("上传新文件");
            $("#uploadArea").slideDown(500);
        }

        function OperateUpload() {
            var fileName = $("#uploadFile").val();
            if (!fileName) {
                OpenAlert("请选择要上传的文件！");
            } else if (!$("#txtFileName").val()) {
                OpenAlert("请指定文件名称！");
            } else {
                $("#btnUpload").click();
            }
        }
        
    </script>
    <style type="text/css">
        #uploadFile{width:200px;border:1px solid lightgray;padding:5px;margin-right:20px;}
        #txtFileName{width:400px;border:1px solid lightgray;padding:5px;}
        .i-con-cn a{cursor: pointer;}
        #btnSave{cursor: pointer;background:#43a9f5;padding:4px 13px;height:auto;width:auto;}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table width="99%" style="table-layout: fixed; margin-top: 5px;" border="0" cellspacing="0"
        cellpadding="0" align="center">
        <tr>
            <td class="xx_m  tt_xx_l">
            </td>
            <td class="xx_m  tt_xx_icon">
            </td>
            <td style="width: auto;" class="xx_m">
                下载管理
            </td>
            <td style="width: 14px;">
                <img src="../images/xx_r.jpg" width="14" height="33" />
            </td>
        </tr>
        <tr>
            <td class="left_con">
                &nbsp;
            </td>
            <td colspan="2" style="padding-left: 6px; padding-right: 6px;" valign="top">
                <div>
                    <div class="xian">
                        <div class="about_title">文件列表</div>
                        <div class="i-con-cn">
                            <span id="del" runat="server">
                                <a onclick="OperateDel();" class="xtbiao">删除</a>
                            </span>
                            <span id="edit" runat="server">
                                <a onclick="OperateReplace();" class="xtbiao">替换</a>
                            </span>
                            <span id="add" runat="server">
                                <a onclick="OperateAdd();" class="xtbiao">添加</a>
                            </span>
                        </div>
                    </div>

                    <telerik:RadGrid ID="fileListGrid" ClientIDMode="Static" runat="server" ShowStatusBar="True" AllowSorting="true"
                        CssClass="tab" AllowFilteringByColumn="false" CellSpacing="0" Culture="zh-CN"
                        GridLines="None" AllowPaging="true" AllowCustomPaging="true" OnNeedDataSource="fileListGrid_NeedDataSource"
                        Width="100%">
                        <MasterTableView AutoGenerateColumns="false" DataKeyNames="ID" NoMasterRecordsText="暂无数据"
                            InsertItemPageIndexAction="ShowItemOnCurrentPage" CommandItemDisplay="Top">
                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="true">
                            </RowIndicatorColumn>
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                </EditColumn>
                            </EditFormSettings>
                            <PagerStyle AlwaysVisible="True" />
                            <CommandItemTemplate>
                            </CommandItemTemplate>
                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="选择" HeaderStyle-Width="10%" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <input type="radio" class="row-radio" fileName="<%#Eval("Name") %>" name="item-sel" id="<%#Eval("ID") %>" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="Name" HeaderText="文件名称" UniqueName="Name"
                                    HeaderStyle-Width="60%" HeaderStyle-HorizontalAlign="Center">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ModifyDate" HeaderText="更新时间" UniqueName="Name"
                                    HeaderStyle-Width="20%" HeaderStyle-HorizontalAlign="Center">
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn HeaderText="操作" HeaderStyle-Width="10%" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <a target="_blank" href="<%#Eval("Path") %>">下载查看</a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                            <Selecting AllowRowSelect="True"></Selecting>
                        </ClientSettings>
                        <PagerStyle AlwaysVisible="True" />
                        <FilterMenu EnableImageSprites="False">
                        </FilterMenu>
                    </telerik:RadGrid>

                    <div id="uploadArea" style="display:none;">
                        <div class="xian">
                            <div class="about_title">文件上传</div>
                        </div>
                        <div>
                            <input id="uploadFile" type="file" runat="server" clientidmode="Static" />
                            文件名：<asp:TextBox ID="txtFileName" runat="server" ClientIDMode="Static" />
                            <span style="display: inline-flex;">
                                <a id="btnSave" onclick="OperateUpload();" class="xtbiao">确认</a>
                            </span>
                        </div>
                    </div>
                </div>
            </td>
            <td class="right_con">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="con_m tt_left_bottom">
                &nbsp;
            </td>
            <td colspan="2" class="con_m">
                &nbsp;
            </td>
            <td class="tt_right_bottom">
                &nbsp;
            </td>
        </tr>
    </table>

    <asp:Button ID="btnUpload" runat="server" ClientIDMode="Static" style="display:none;"
        onclick="btnUpload_Click" />

    <asp:HiddenField ID="hidFileID" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hidOperaType" ClientIDMode="Static" runat="server" />
</asp:Content>